package com.sirdc.modules.bnp.dao;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.sirdc.modules.bnp.filter.SysNodeScheduleFilter;
import com.sirdc.modules.core.dao.GenericQuery;
import com.sirdc.modules.core.dao.StringDao;

import net.huashitong.node.entity.NodeSchedules;

@Repository
public class SysNodeScheduleDao extends StringDao<NodeSchedules> {
	
	public List<NodeSchedules> query(SysNodeScheduleFilter filter,String proId){
		GenericQuery query = createQuery("obj");
		query.append(" and obj.projectId = :projectId").setParam("projectId", proId);
		return query.listResult(filter);
	}
	public NodeSchedules getNodeSchedules(String proId,String nodeId){
		GenericQuery query = createQuery("obj");
		query.append(" and obj.projectId = :projectId").setParam("projectId", proId);
		query.append(" and obj.nodeId = :nodeId").setParam("nodeId", nodeId);
		return query.singleResult();
	}
	public void setNodeInfo(String sysId,String resUser,String resUserPhone,String planTime){
		String hql = "update NodeSchedules set resUser=:resUser,resUserPhone=:resUserPhone,planTime=:planTime where sysId=:sysId";
		GenericQuery query = create(hql);
		query.setParam("resUser", resUser);
		query.setParam("resUserPhone", resUserPhone);
		query.setParam("planTime", planTime);
		query.setParam("sysId", sysId);
		query.executeUpdate();
	}
	/*public void setNodeModel(){
		String hql = "delete from SysRolePermission where roleId=:roleId and deptId=:deptId";
		GenericQuery query = create(hql);
		query.setParam("roleId", 1);
		query.setParam("deptId", 1);
		query.executeUpdate();
	}
*/
	public void deleteByProjectId(String projectId){
		String hql ="delete from NodeSchedules where projectId=:projectId";
		GenericQuery query = create(hql);
		query.setParam("projectId", projectId);
		query.executeUpdate();
	}
	
}
